package com.kexun.servlet.admin;

import com.kexun.pojo.User;
import com.kexun.service.AdmService;
import com.kexun.service.impl.AdmServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/ServletAdmInfo")
public class ServletAdmInfo extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        HttpSession session = request.getSession();
        User user1 = (User) session.getAttribute("user");
        String userNum = user1.getUserNum();


        AdmService as = new AdmServiceImpl();
        User user = as.findInfo(userNum);
        if(user!=null){
           session.setAttribute("user",user);
           request.getRequestDispatcher("admin/adminInfo.jsp").forward(request,response);
        }



    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
